﻿using SuperSocket.ClientEngine;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace superSocketClient
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MyClient client = new MyClient();
            client.Initialize(new MyuReceiveFilter(4), (info =>
            {
                Console.WriteLine(info.Key);
            }));


            var flag = client.ConnectAsync(new DnsEndPoint("127.0.0.1", 6679));
            if (flag.Result)
            {
                StringBuilder str = new StringBuilder();
                //str.Append("Login ");
                for (int i = 0; i < 4; i++)
                {
                    str.Append("Igiveyou");
                }
                str.Append("\r\n");
                byte[] b = Encoding.ASCII.GetBytes(str.ToString());
                client.Send("Logn", b);
            }
            //    string strText = "add 1 1\r\n";
            //if (client != null && client.IsConnected)
            //{
            //    Byte[] smk = new Byte[strText.Length];
            //    for (int i = 0; i < strText.Length; i++)
            //    {
            //        Byte ss = Convert.ToByte(strText[i]);
            //        smk[i] = ss;
            //    }
            //    byte[] b = Encoding.ASCII.GetBytes("ECHO 1 1\r\n");
            //    client.Send(smk.ToArray());  //EasyClient<MyPackageInfo> client
            //}
        }
    }
}
